<template>
	<view class="content">
		<view class="newsContent" v-for="item in newslist" :data-Businessid="item.id" @click="goDetails">
				<view class="newsContentBox" v-if="item.image_main[0]">
					<image :src="address+item.image_main[0].image_id" mode="aspectFill"></image>
				</view>
				<!-- <view class="newsContentBox">
					<image :src="address+item.image_main[0].image_id+'?imageView2/1/w/100/h/100'" mode=""></image>
				</view> -->
				<view class="newsContentText" >
					<view class="newsContentTextTitle">
						<text>{{item.name}}</text>
					</view>
					<view class="newsContentTime">
						<view class="newHidden">
							{{item.info}}
						</view>
						<view class="newsData" style="float: right;">{{item.time}}</view>
					</view>
				</view>
			
		</view>
		<view v-if="status" style="width: 100%; text-align: center; font-size:32upx; color: #B2B2B2;">
			{{status}}
		</view>
		<uni-load-more  v-if="displayl" :loadingType="loadingType"  :contentText="contentText"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import uniIcon from "@/components/uni-icon/uni-icon.vue"
	import eonfox from "@/components/eonfox/eonfox.js"
	import fns from '@/components/eonfox/fns.js';
	var ef = new eonfox();
	export default {
		name:"news",
		data() {
			return {
				newslist:[],
				newsId:'',
				newsListID:'',
				address:'',
				page:10,
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				status:'',
				displayl:false,
				keywords:''
			};
		},
		onLoad(e){
			console.log('消息列表',e)
			this.keywords=e.searchName
			this.newsListID=e.newsId;
			this.load();
		},
		components:{
			uniIcon,uniLoadMore
		},
		onReachBottom() {
					if (this.loadingType !== 0) {
						return;
					}
					this.loadingType = 1;
					var _this=this;
					
					// _this.page=_this.page++;
					
					uni.showLoading({
						title:'正在加载',
						success() {
							_this.load();
						}
					})
		},
		methods:{
			load(){
					var that=this;
					   that.page=that.page+10
					ef.submit({
					request:{
					s: ['CMSARTICLELIST',[{search:{type_id:that.newsListID,keywords:that.keywords},size:that.page}]],
					config: ['APPLICATIONCONFIG']
					},
					callback: function(data) {
						console.log(data)
						if (fns.checkError(data, ["s","config"],function(erron, error) {
											uni.showToast({
												title: error,
												icon: 'none'
											})
										}));
							that.address=data.data.config.data.qiniu_domain;//获取七牛的域名			
							
							if(data.data.s.data.data){
							   // that.contentText=that.contentText.contentnomore;
							   that.newslist=data.data.s.data.data;
							   if(that.newslist.length<10){
							   	that.loadingType=2
							   }
							}
							if(that.newslist.length==0){
								 that.status="暂无数据"
                                 that.displayl=false;
							}
							else{
								that.displayl=true;
							}
							
							console.log('输出',that.newslist)
							console.log('输出',that.address)
							},				
                	error: function(err) {
									uni.showToast({
									title:'出错啦',
									icon:'none'
										})
										}
										
									});
			},
			goDetails:function(e){
				var newsId=e.currentTarget.dataset.businessid;
				console.log("目标",newsId);
				uni.navigateTo({
					url:'../../pagesA/InformationDetails/InformationDetails?newsId='+newsId  
					// 参数的传递 newsid 
				});
			}
			
		}
	}
</script>

<style>
	.content{
		width: 96%;
		padding-left: 2%;
		padding-right: 2%;
		height: auto;
		font-size: 24upx;
	}
	.newsContent{
		width: 100%;
		height:170upx;
		display: flex;
		overflow: hidden;
		padding-top: 10upx;
		padding-bottom: 10upx;
		border-bottom: #E3E3E3 solid 1upx;
	}
	.newsContentBox{
		width: 150upx;
		height: 150upx;
		margin-top:10upx;
		margin-right:8upx;
	}
	.newsContentBox image{
		width: 100%;
		height: 100%; 
	}
	.newsContentText{
		/* width: 580upx; */
		height: 150upx;
		width: 100%;
	}
	.newsContentTime{
		width: 100%;
		height: 50upx;
		color: #555555;
	}
	.newsContentTextTitle{
		width: 100%;
		height: 80upx;
		font-size: 30upx;
		overflow: hidden;
		margin-top: 30upx;
		color: #444444;
	}
	.newHidden{
		float:left;
		width: 70%;
		overflow:hidden;
		text-overflow: ellipsis;
		height:30upx;
        white-space:nowrap;

	}
	.newsData{
		float:right;
		width:130upx;
		height: 50upx;
	}
	
</style>

